import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:provide/provide.dart';
import 'package:qgchat/states/states_model/user.dart';
import 'package:qgchat/widgets/easyRefreshWidget.dart';

import 'widget/UserCard/UserCard.dart';
import 'widget/UserTabList/UserTabList.dart';
import 'widget/Header/TopHeader.dart';

class My extends StatefulWidget {
  My({Key key}) : super(key: key);

  @override
  _MyState createState() => _MyState();
}

class _MyState extends State<My> {
  @override
  void initState() {
    super.initState();
    if (mounted) {
      Timer(Duration(milliseconds: 500), () {
        setState(() {});
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: EasyRefresh(
        header: EasyRefreshSetting.header,
        onRefresh: () async {
          Provide.value<UserState>(context).userInfo();
        },
        child: Stack(
          children: <Widget>[
            Image.asset('assets/images/nav-bar.png'),
            SafeArea(
              child: Column(
                children: <Widget>[
                  /// 标题
                  TopHeader(),

                  /// 用户卡片
                  UserCard(),

                  /// 用户可操作列表
                  UserTabList(),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
